
#include "driver/i2c_master.h"

#include "esp_err.h"
#include "esp_log.h"

#define TAG "bsp_i2c"
i2c_master_bus_handle_t bsp_i2c_bus = NULL;

esp_err_t bsp_i2c_init(void)
{
    ESP_LOGI(TAG, "Initialize I2C bus");
    
    i2c_master_bus_config_t bus_config = {
        .clk_source = I2C_CLK_SRC_DEFAULT,
        .glitch_ignore_cnt = 7,
        .i2c_port = I2C_NUM_0,
        .sda_io_num = 1,
        .scl_io_num = 2,
        .flags = {
            .enable_internal_pullup = 1,
        }
    };
    ESP_ERROR_CHECK(i2c_new_master_bus(&bus_config, &bsp_i2c_bus));


 
    return ESP_OK;    
};
